<%@ page contentType="text/html; charset=utf-8" pageEncoding="utf-8" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="f" uri="http://java.sun.com/jsp/jstl/fmt" %>
<%@ taglib prefix="s" uri="http://stripes.sourceforge.net/stripes.tld" %>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>

<fmt:bundle basename="StripesResources" /> 
<fmt:message key='adminPageGhosts' var="title"/>
<s:layout-render name="adminlayout.jsp" nadpis="${title}">
    <s:layout-component name="telo">
        <s:useActionBean beanclass="cz.muni.fi.pa165.hauntedhouses.web.AdminGhostsActionBean" var="actionBean"/>
        <center>
            <c:choose>
                <c:when test="${fn:length(actionBean.ghosts) == 0}">
                    <div><font style="color: red;" ><fmt:message key="menu.noghosts"/></font></div><br /><br />
                </c:when>
                <c:otherwise>
                    <table class="zakladni">
                        <tr>
                            
                            <th><fmt:message key="admin.ghostName"/></th>
                            <th><fmt:message key="admin.ghostDescription"/></th>
                            <th><fmt:message key="admin.ghostLevel"/></th>
                            <th><fmt:message key="admin.ghostExperience"/></th>
                            <th><fmt:message key="admin.ghostAbility"/></th>
                            <th><fmt:message key="admin.ghostAbilityType"/></th>
                            <th><fmt:message key="admin.ghostLastHaunted"/></th>
                            <th><fmt:message key="admin.ghostEdit"/></th>
                            <th><fmt:message key="admin.ghostDelete"/></th>
                        </tr>
                        <c:forEach items="${actionBean.ghosts}" var="ghost">
                            <tr>
                                             
                                <td><c:out value="${ghost.name}"/></td>
                                <td><c:out value="${ghost.description}"/></td>
                                <td><c:out value="${ghost.lvl}"/></td>
                                <td><c:out value="${ghost.experience}"/></td>
                                <td><s:link beanclass="cz.muni.fi.pa165.hauntedhouses.web.AdminGhostsActionBean" event="manageAbilities"><s:param name="ghost.id" value="${ghost.id}"/><fmt:message key="admin.abilityManagement"/></s:link></td>
                                <td><c:out value="${ghost.abilityType}"/></td>
                                <td><fmt:formatDate value="${ghost.lastHaunted}" pattern="MM/dd/yyyy"/> </td>
                                <td><s:link beanclass="cz.muni.fi.pa165.hauntedhouses.web.AdminGhostsActionBean" event="edit"><s:param name="ghost.id" value="${ghost.id}"/><fmt:message key="admin.abilityEdit"/></s:link> </td>
                                <td><s:link beanclass="cz.muni.fi.pa165.hauntedhouses.web.AdminGhostsActionBean" event="delete"><s:param name="ghost.id" value="${ghost.id}"/><fmt:message key="admin.abilityDelete"/></s:link> </td>
                                </tr>
                        </c:forEach>
                    </table>
                </c:otherwise>
            </c:choose>
            <s:form style="width:400px" beanclass="cz.muni.fi.pa165.hauntedhouses.web.AdminGhostsActionBean">
                <br /><fieldset><legend><fmt:message key="admin.newGhost"/></legend>
                    <%@include file="adminGhostForm.jsp"%>
                    <s:submit name="add"><fmt:message key="admin.createNewGhost"/></s:submit>
                    </fieldset>
            </s:form>
        </center>
    </s:layout-component>
</s:layout-render>